#!/opt/csw/bin/perl -w
use strict;
use YAML;
use Data::Dumper;
use SecurityCenter;
use CenterFactory;
use DataCollectionChannel;
use CollectionChannelFactory;
use DataAccessLayerFactory; 
use DataDumpingManager; 

my $database_config_file = "configuration/data_access.conf";
my $dal_manager = DataAccessLayerFactory::new();
my ($dal, $dal_msg) = $dal_manager->load_data_access_layer_from_yaml_file($database_config_file);
if(!$dal){	 	
	print $dal_msg;
	exit;
}
# Load a YAML stream of 3 YAML documents into Perl data structures.
my $center_manager = CenterFactory::new();
my ($centers, $message) = $center_manager->load_centers_from_yaml_file("configuration/security_centers.conf");
my $channel_manager = CollectionChannelFactory::new();
my ($channels, $mymessage) = $channel_manager->load_channels_from_yaml_file("configuration/collection_channels.conf");
my ($gov_hose, $mssg) = $channel_manager->get_channel_by_name("HSC_HoSE", $channels);

if (ref($gov_hose)){
	while(1){
		$gov_hose->{DELAY_TIME} = 100;
	 	my ($stock_info_set, $msg) = $gov_hose->get_stock_info_set(500);
	 	if(ref($stock_info_set)){
	 		
	 		#$dal->insert_stock_info_set($stock_info_set);		
	 	}else{
	 		print Dumper($msg);
	 	} 	
	 	sleep(5);
	}
 	 	 	 	
 }else{
 	print $mssg;
 }
 while(1){
 	sleep(30);
 }
 
